<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//Route::get('/', function () {
//    return view('welcome');
//});

//后台路由
Route::group (['middleware'=>['auth.admin'],'prefix'=>'admin','as'=>'admin.','namespace'=>'Admin'],function (){
    Route::get ('/','HomeController@index')->name ('home');
    //配置项管理路由
    Route::get ('config/edit/{name}','ConfigController@edit')->name ('config.edit');
    Route::post ('config/update/{name}','ConfigController@update')->name ('config.update');
    Route::resource('category','CategoryController');
});
//前台路由
Route::group (['namespace'=>'Home'],function (){
    Route::get('/', 'IndexController@index')->name ('index');
    Route::get('/login', 'LoginController@login')->name ('login');
    Route::post('/login', 'LoginController@store')->name ('login');
    Route::resource ('user','UserController');
    Route::get('/logout','LoginController@logout')->name('logout');
    Route::resource('article','ArticleController');
//    Route::get('/zan/{article}','ArticleController@ToggleZan')->name('zan');
    Route::resource('topic','TopicController');
    Route::get('/lesson/lists','LessonController@lists')->name('lesson.lists');
    Route::resource('lesson','LessonController');
    Route::resource('video','VideoController');

});
//工具路由
Route::group (['namespace'=>'Util'],function (){
    Route::any('code/send', 'CodeController@send')->name ('code.send');
    Route::any ( '/upload/upload' , 'UploadController@upload' )->name ( 'upload.upload' );
    Route::any ( '/upload/lists' , 'UploadController@lists' )->name ( 'upload.lists' );
});
//会员中心
Route::group ( [ 'middleware' => [] , 'prefix' => 'member' , 'as' => 'member.' , 'namespace' => 'Member' ] , function () {
    Route::get ( '/' , 'UserController@index' )->name ( 'index' );
    Route::resource ( 'user' , 'UserController' );
    Route::resource('notify','NotifyController');
    Route::get ( '/follow/{user}' , 'UserController@follow' )->name ( 'follow' );
    Route::get('/user/getFans/{user}','UserController@getFans')->name('user.getFans');
    Route::get('/user/getFollower/{user}','UserController@getFollower')->name('user.getFollower');


} );
//公共类
Route::group ( [ 'middleware' => [] , 'prefix' => 'common' , 'as' => 'common.' , 'namespace' => 'Common' ] , function () {
    Route::resource ( 'comment' , 'CommentController' );
    Route::get('/favorite/make','FavoriteController@make')->name('favorite.make');
    Route::get('/zan/make','ZanController@make')->name('zan.make');
} );

